import http from "@/api/admin-http.js";

export const employeeLogin = async (ruleForm) => {
    return await http.post("/admin/employee/login",ruleForm)
}

/**
 * 查询所有员工
 * @param ruleForm
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const employeePageQuery = async (queryParam) => {
    if(queryParam.name){
        return await http.get(`/admin/employee/page?name=${queryParam.name}&page=${queryParam.page}&pageSize=${queryParam.size}`)

    }
    return await http.get(`/admin/employee/page?page=${queryParam.page}&pageSize=${queryParam.size}`)
}

/**
 * 添加员工
 * @param ruleForm
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const addEmployee = async (ruleForm) => {
    return await http.post("/admin/employee",ruleForm)
}

/**
 * 修改员工
 * @param ruleForm
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const updateEmployee = async (ruleForm) => {
    return await http.put("/admin/employee",ruleForm)
}

/**
 * 根据id获取
 * @param ruleForm
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const getById = async (id) => {
    return await http.get("/admin/employee/"+id)
}

/**
 * 启用禁用账号
 * @param ruleForm
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const startOrStop = async (status,id) => {
    console.log(status,id)
    return await http.post("/admin/employee/status/"+status+"?id="+id)
}

/**
 * 根据id删除员工
 * @param ruleForm
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const deleteById = async (id) => {
    console.log(id)
    return await http.delete("/admin/employee/"+id)
}


/**
 * 修改密码
 * @param ruleForm
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const updatePassword = async (updatePwdForm) => {
    console.log(updatePwdForm)
    return await http.put("/admin/employee/pass",updatePwdForm)
}


/**
 * 获取所有用户
 * @param param
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const userPageQuery = async (param) => {
    if(param.name){
        return await http.get('/admin/user/list?page='+param.page+'&pageSize='+param.size+"&name="+param.name)
    }
    return await http.get('/admin/user/list?page='+param.page+'&pageSize='+param.size)
}

/**
 * 启用禁用用户账号
 * @param status
 * @param id
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const startOrStopUser = async (status,id) => {
    console.log(status,id)
    return await http.post("/admin/user/status/"+status+"?id="+id)
}



/**
 * 根据id删除用户
 * @param id
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const deleteUserById = async (id) => {
    console.log(id)
    return await http.delete("/admin/user/"+id)
}

/**
 * 获取本周最热的五个视频
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const getHotVideos = async () => {
    return await http.get(`/user/recommend/hot-videos`)
}

/**
 * 获取最近的统计数据
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const getAdditionalStat = async (endTime,dateCount) => {
    return await http.get(`/admin/stat/additional?endTime=${endTime}&dateCount=${dateCount}`)
}


/**
 * 获取所有统计数据
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const getAllStat = async () => {
    return await http.get(`/admin/stat/all`)
}

/**
 * 获取最近七天的视频和用户数据
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const getRecentUserAndVideoStat = async (dateCount) => {
    return await http.get(`/admin/stat/list?dateCount=${dateCount}`)
}




/********************* 审核管理 *********************/

/**
 * 获取所有待审核的数据
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const getPendingVideo = async (param) => {
    if(param.name){
        return await http.get(`/admin/pending/all?page=${param.page}&pageSize=${param.size}&name=${param.name}`)
    }
    return await http.get(`/admin/pending/all?page=${param.page}&pageSize=${param.size}`)

}

/**
 * 获取所有待审核的数据
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const setFinalStatus = async (form) => {
    console.log(form)
        return await http.put(`/admin/pending`,form)
}


/**
 * 根据id删除待审核视频
 * @param id
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const deleteVideoById = async (id) => {
    console.log(id)
    return await http.delete("/admin/pending/"+id)
}
/********************* 审核管理结束 *********************/


/********************* 分区管理 *********************/
/**
 * 获取分区列表
 * @param param
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const categoryPageQuery = async (param) => {
    console.log(param)
    if(param.name){
        return await http.get(`/admin/partition/list?page=${param.page}&pageSize=${param.size}&name=${param.name}`)
    }
    return await http.get(`/admin/partition/list?page=${param.page}&pageSize=${param.size}`)
}

/**
 * 删除分区
 * @param id
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const deletePartitionById = async (id) => {
    console.log(id)
    return await http.delete(`/admin/partition/${id}`)
}

/**
 * 新增分区
 * @param form
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const insertPartition = async (form) => {
    console.log(insertPartition)
    return await http.post(`/admin/partition`,form)
}


/********************* 分区管理结束 *********************/


/********************* banner管理 *********************/
/**
 * 获取banner列表
 * @param param
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const bannerPageQuery = async (param) => {
    console.log(param)
    if(param.name){
        return await http.get(`/admin/banner/list?page=${param.page}&pageSize=${param.size}&name=${param.name}`)
    }
    return await http.get(`/admin/banner/list?page=${param.page}&pageSize=${param.size}`)
}

/**
 * 删除banner
 * @param id
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const deleteBannerById = async (id) => {
    console.log(id)
    return await http.delete(`/admin/banner/${id}`)
}

/**
 * 新增banner
 * @param form
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const insertBanner = async (form) => {
    console.log(insertPartition)
    return await http.post(`/admin/banner`,form)
}


/********************* banner管理结束 *********************/


/********************* 视频管理 *********************/
export const videoPageQuery = async (param) => {
    console.log(param)
    if(param.name){
        return await http.get(`/admin/video/list?page=${param.page}&pageSize=${param.size}&keyword=${param.name}`)
    }
    return await http.get(`/admin/video/list?page=${param.page}&pageSize=${param.size}`)
}

export const removeVideoById = async (id) => {
    console.log(id)
    return await http.delete(`/admin/video/${id}`)
}
/********************* 视频管理结束 *********************/


